﻿/**  版本信息模板在安装目录下，可自行修改。
* Products.cs
*
* 功 能： N/A
* 类 名： Products
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2016/7/10 16:28:10   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace Maticsoft.DAL
{
	/// <summary>
	/// 数据访问类:Products
	/// </summary>
	public partial class Products
	{
        /// <summary>
        /// 显示/隐藏数据
        /// </summary>
        /// <param name="ids">逗号隔开的id串</param>
        /// <param name="opeType">操作类型1上架0下架</param>
        /// <returns></returns>
        public int HiddenShow(string ids, int opeType)
        {
            string sqlStr = "update Products set isHid="+opeType+" where productId in(" + ids + ")";

            return DbHelperSQL.ExecuteSql(sqlStr);
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPageView(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.ProductId desc");
            }
            strSql.Append(")AS Row, T.*  from v_Products T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 逻辑删除产品
        /// </summary>
        /// <param name="ids">逗号分隔id字符串</param>
        /// <returns>执行记录数</returns>
        public int DelLogic(string ids)
        {
            string sqlStr = "update Products set IsActive=0 where productId in(" + ids + ")";

            return DbHelperSQL.ExecuteSql(sqlStr);
        }
	}
}

